#include<iostream>
using namespace std;
const int N = 3e3 + 10;
int arr[N];
int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	int mi = 100000;
	for (int i = 0; i < n - m; i++) {
		int sum = arr[i];
		for (int j = i + 1; j < i + m; j++) {
			sum += arr[j];
		}
		if (sum < mi) {
			mi = sum;
		}
	}
	cout << mi << endl;
	return 0;
}